// Package global
// @Author: zhangdi
// @File: flag
// @Version: 1.0.0
// @Date: 2023/5/23 17:05
package entry

import (
	"ideatools/application/constant"
	"ideatools/application/core/handler"
	"ideatools/application/pkgs/mylog"
	"ideatools/application/pkgs/startup"
	"ideatools/setting"

	//"ideatools/application/constant/lang"
	"ideatools/application/db/dbservice"
	"ideatools/application/service"
)

var ClipService *service.ClipListenService
var ClipDbService *dbservice.ClipboardService

//var MouseService *service.MouseListenService //鼠标按键监听--快速启动

// var KeyboardService *service.ListenKeyboardService //监听键盘按键-快捷键
var KmListenService *service.KMListener  //监听鼠标、键盘按键-快捷键
var SystemService *service.SystemService //监听键盘按键-快捷键
var BackService *service.BackService     //监听键盘按键-快捷键

var ConfigService *dbservice.DbConfigService //配置读写--数据库版
// var LangService *dbservice.DbLangService       //语言包
var UserToolService *dbservice.UserToolService //用户工具
var HandlerMessageService *handler.HandlerMessageService
var ChatDialogService *dbservice.DbChatDialogService

func InitService(ProjectName string) {
	ClipService = service.StartClipListenService(3) //剪切板相关对象
	ClipDbService = dbservice.NewClipboardService()

	SystemService = service.NewSystemService(ProjectName)

	ConfigService = dbservice.NewDbConfigService() //配置读写--数据库版

	KmListenService = service.NewListener(
		CallBackMouseLongClick,
		CallBackKeyboardClick,
		CallBackOneKeyClick,
	)
	//MouseService = service.StartMouseListenService(CallbackMouse) //鼠标按键监听--快速启动
	//
	//KeyboardService = service.StartListenKeyboardService(CallbackKeyboard) //监听键盘按键-快捷键

	//LangService = dbservice.NewDbLangService(dbservice.LanguageTypeCn) //语言包

	UserToolService = dbservice.NewUserToolService() //用户工具
	HandlerMessageService = handler.NewHandlerMessageService()

	BackService = service.NewBackService()

	ChatDialogService = dbservice.NewChatDialogService()

	//初始化gpt
	handler.InitGpt()

	//添加-开机自启
	err := startup.SetAutoStart(setting.ProjectName, ConfigService.GetBool(constant.ConfigKeySysAutoStart))
	if err != nil {
		mylog.Error("开机自启 error" + err.Error())
	}

	//设置快捷键监和键盘前端的监听是false
	SystemService.StoptListenKeyboard()
	SystemService.StopListenMouseLong()

}
